import Vue from 'vue'
import Vuex from 'vuex'
import cart from './modules/cart.js'
import createPersistedState from "vuex-persistedstate"

Vue.use(Vuex); //vue的插件机制

//Vuex.Store 构造器选项
export default new Vuex.Store({
	state:{
		IP:"http://localhost:9999/",
		// IP:"http://47.106.199.123:9999/",
		Account:{
			openId:"",
			nickName:"",
			avatar:""
		}
			
	},
	
	modules: {
		cart
	},
	plugins: [createPersistedState({
		key: 'app_config_data', // 状态保存到本地的 key   
		storage: { // 存储方式定义  
			getItem: (key) => uni.getStorageSync(key), // 获取  
			setItem: (key, value) => uni.setStorageSync(key, value), // 存储  
			removeItem: (key) => uni.removeStorageSync(key) // 删除  
		}
	})]
})
